package com.inexas.cu.guice;

import com.google.inject.*;

public class GuiceFactory {
	private static Injector injector;

	public static Injector getInjector(Module... modules) {
		if(injector != null) {
			throw new RuntimeException("GuiceFactory already initialized, you can do this once only");
		}
		injector = Guice.createInjector(modules);
		return injector;
	}


	public static Injector getInjector() {
		if(injector == null) {
			throw new RuntimeException(	//
					"The first call to GuiceFactory must include a module list, " +	//
					"use 'getInjector(Module... modules)' insead");
		}
		return injector;
	}
}
